{% include 'QLGL/QLGL_index.html' %}

<div class="am-cf admin-main">
  {% include 'sidebar.html' %}
  <!-- content start -->
  <div class="admin-content">
    <div class="admin-content-body">
      <div class="am-cf am-padding">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">巡检业务</strong></div>
      </div>
      <div class="am-g" style="position: absolute;height: 100%;right: 0px;left: 260px;width: auto;">

        {% include 'QLGL/XJYW/QLGL_XJYW_SIDEBAR.html' %}
        
        <div class="am-u-sm-10" style="position: absolute;width:auto;right:0;left: 200px;overflow-y: scroll;bottom: 100px;top: 0px;">
          <div class="am-u-sm-12 am-u-md-6">
            <div class="am-btn-toolbar">
              <div class="am-btn-group am-btn-group-xs">
                <button style="margin: 0 5px"  type="button" class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick=""><span class="am-icon-plus"></span>新增</button>
              </div>
            </div>
          </div>

          <table id="grid" class="am-table am-table-striped am-table-hover table-main am-table-compact am-text-nowrap" >
            <thead>
              <tr>
                <th class="table-title">任务</th>
                <th class="table-set">操作</th>
              </tr>
            </thead>
            <tbody></tbody>
          </table>

        </div>
      </div>
    </div>
  </div>
</div>
{% include 'footer.html' %}
<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="/static/assets/js/jquery.min.js"></script>
<!--<![endif]-->
<script src="/static/assets/js/amazeui.min.js"></script>
<script src="/static/assets/js/amazeui.tree.js"></script>
<script type="text/javascript" src="/static/assets/js/layer.js"></script>
<script src="/static/assets/datatables/amazeui.datatables.min.js"></script>
<script src="/static/assets/dialog/amazeui.dialog.min.js"></script>
<link rel="stylesheet" type="text/css" href="/static/assets/css/amazeui.tree.css" />
<script src="/static/assets/js/app.js"></script>
<style type="text/css">
  .li_a {
    color: #5c5c5c;
  }
</style>
<script type="text/javascript">
  $("#collapse-nav1").addClass("am-in");
  $("#qlgl").removeClass("am-collapsed");
  $("#qlglOxjyw").css("color", "#3399CC");
  $("#qlgl").css("color", "#3399CC");
  $("#xjywOrcxc").removeClass("li_a");

// var t = $('#grid').DataTable({
//   //配置DataTables默认参数



//     bInfo: true,//页脚信息
//     responsive: true,
//     searching: true,
//     lengthChange: false,
//     paging: true,
//     bStateSave: true, //保存页面状态
//     aLengthMenu: [[10], [10]],

var t = $('#grid').DataTable({
    bInfo: false,//页脚信息
    responsive: true,
    searching: false,
    lengthChange: false,
    paging: false,
    ajax: {

      url: "/getDCLJson/"
    },
    //每页显示五条数据
    //pageLength: 'all',
    columns: [{
        "data": "task_id"
      },
      {
        "data": "type"
      }
    ],
    "columnDefs": [
      // "visible": false,
      //"targets": 0
      {
        type: 'chinese-string',
        targets: '_all'
      } //中文排序

      ,
      {
        "render": function(data, type, row, meta) {
          //渲染 把数据源中的标题和url组成超链
          //   return '<a href="/app_XCZ/RW/?taskid=' + row.task_id + '" target="_blank">' + row.content + '</a>';
          if(row.role_code == "inspection") {
            return '<a href="/CheckWeather/' + row.task_id + '" target="_self">' + row.content + '</a>';
          } else if(row.role_code == "maintenance") {
            return '<a href="/RW/?taskid=' + row.task_id + '" target="_self">' + row.content + '</a>';
          } else if(row.role_code == "technology") {
            if(row.category == 2) {
              if(row.type == 1) {
                return '<a href="/app_JSZ/RW_XC/?assign_id=' + row.assign_id + '" target="_self">' + row.content + '</a>';
              } else if(row.type == 2) {
                return '<a href="/BHXQ/' + row.assign_id + '" target="_self">' + row.content + '</a>';
              } else if(row.type == 3) {
                return '<a href="/RW_GZ/?assign_id=' + row.assign_id + '" target="_self">' + row.content + '</a>';
              } else if(row.type == 4) {
                return '<a href="/RW_WH/?assign_id=' + row.assign_id + '" target="_self">' + row.content + '</a>';
              }
            } else {
              if(row.type == 4) {
                return '<a href="/RW_WH/?assign_id=' + row.assign_id + '" target="_self">' + row.content + '</a>';
              } else {
                return '<a  target="_self">' + row.content + '</a>';
              }
            }
          }

        },
        //指定是第一列
        "targets": 0
      },
      {
        "render": function(data, type, row, meta) {
          //渲染 把数据源中的标题和url组成超链
          //   return '<a href="#" onclick="confirmSave('+row.taskid+')">完成任务</a>';
          if(row.role_code == "inspection") {
            return '<div class="am-btn-group am-btn-group-xs"><button class="am-btn am-btn-default am-btn-xs am-text-secondary" style="padding:3px 6px"  onclick="confirmSave_XCZ(' + row.task_id + ')">完成</button></div>';
          } else if(row.role_code == "maintenance") {
            return '<div class="am-btn-group am-btn-group-xs"><button class="am-btn am-btn-default am-btn-xs am-text-secondary" style="padding:3px 6px" onclick="confirmSave_WHZ(' + row.task_id + ')">完成</button></div>';
          } else if(row.role_code == "technology") {
            if(row.category == 2) {
              return '<div class="am-btn-group am-btn-group-xs"> <button class="am-btn am-btn-default am-btn-xs am-text-secondary" style="padding:3px 6px" onclick="confirmSave_JSZ(' + row.assign_id + ',2)">不处理</button><button   class="am-btn am-btn-default am-btn-xs am-text-secondary" style="padding:3px 6px" onclick="confirmSave_JSZ(' + row.assign_id + ',3)">跟踪</button><button   class="am-btn am-btn-default am-btn-xs am-text-secondary" style="padding:3px 6px" onclick="confirmSave_JSZ(' + row.assign_id + ',4)">维护</button><button   class="am-btn am-btn-default am-btn-xs am-text-secondary" style="padding:3px 6px" onclick="confirmSave_JSZ(' + row.assign_id + ',5)">维修</button></div>';
            } else {
              return '<div class="am-btn-group am-btn-group-xs"><button class="am-btn am-btn-default am-btn-xs am-text-secondary" style="padding:3px 6px" onclick="confirmSave_JSZ(' + row.assign_id + ',1)">已阅知</button></div>';
            }
          }

        },
        //指定是第二列
        "targets": 1
      }
    ]

  });

  var confirmSave_XCZ = function(id) {
    AMUI.dialog.confirm({
      title: '任务完成',
      content: '即将完成任务，请确认保存?',
      onConfirm: function() {
        console.log('onConfirm,save ' + id);

        $.ajax({
          "url": "/writeDCLXC/?taskid=" + id + "",
          "datatype": "json",
          "type": "get",
          "async": "false"
        }).success(function(data) {
          if(data.status == 1) {
            //AlertMSG1(data.message);
            window.location.reload();
          } else if(data.status == 2) {
            AlertMSG(data.message);
            window.location.reload();
          } else {
            AlertMSG(data.message);
          }
        }).error(function(data) {
          AlertMSG("提交失败！");
        });

        //完成任务，修改数据
      },
      onCancel: function() {
        console.log('onCancel')
      }
    });
  };

  var confirmSave_WHZ = function(id) {
    AMUI.dialog.confirm({
      title: '任务完成',
      content: '即将完成任务，请确认保存?',
      onConfirm: function() {
        console.log('onConfirm,save ' + id);
        $.ajax({
          "url": "/writeDCLWH/?taskid=" + id + "",
          "datatype": "json",
          "type": "post",
          "async": "false"
        }).success(function(data) {
          if(data.status == 1) {
            //AlertMSG1(data.message);
            window.location.reload();
          } else if(data.status == 2) {
            AlertMSG(data.message);
            window.location.reload();
          } else {
            AlertMSG(data.message);
          }
        }).error(function(data) {
          AlertMSG("提交失败！");
        });
        //完成任务，修改数据
      },
      onCancel: function() {
        console.log('onCancel')
      }
    });
  };
  var confirmSave_JSZ = function(id, type) {
    AMUI.dialog.confirm({
      title: '任务完成',
      content: '即将完成任务，请确认保存?',
      onConfirm: function() {
        //console.log('onConfirm,save '+id);
        $.ajax({
          "url": "/writeDCLJS/?assign_id=" + id + "&type=" + type + "",
          "datatype": "json",
          "type": "post",
          "async": "false"
        }).success(function(data) {
          if(data.status == 1) {
            //AlertMSG1(data.message);
            window.location.reload();
          } else if(data.status == 2) {
            AlertMSG(data.message);
            window.location.reload();
          } else {
            AlertMSG(data.message);
          }
        }).error(function(data) {
          AlertMSG("提交失败！");
        });
        //完成任务，修改数据
      },
      onCancel: function() {
        console.log('onCancel')
      }
    });
  };








  

  function popup(title,url){
        var index = layer.open({
            type: 2,
            title: title,
            content: url,
            area: ['600px', '360px'],
            
        });

        
        //铺满界面
        //layer.full(index);
  }
  var AlertMSG=function(msg){
    AMUI.dialog.alert({ title: '错误提示', content: msg, onConfirm: function() { console.log('close'); } });
  }







</script>
 
</body>

</html>